package com.tengju.bff.interfaces.shared;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PhpAppResponse<T> {

    private int code;
    private String msg;
    private T data;

    public static <T> PhpAppResponse<T> success(T data) {
        return new PhpAppResponse<>(0, "success", data);
    }


    public static <T> PhpAppResponse<T> error(String msg) {
        return new PhpAppResponse<>(8002, msg, null);
    }


    public static <T> PhpAppResponse<T> error(int code, String msg) {
        return new PhpAppResponse<>(code, msg, null);
    }



    public static <T> PhpAppResponse<T> paramError() {
        return new PhpAppResponse<>(8003, "参数有误", null);
    }


    public static <T> PhpAppResponse<T> paramError(String msg) {
        return new PhpAppResponse<>(8003, msg, null);
    }
}
